import React from "react"
import ProductCar from "../组件通信/子传父.js";
import TabControl from "./TabControl"

export default class App extends React.Component {
    constructor(props) {
        super(props);

        this.titles = ["新款","精选","流行"]
        this.state = {
            selectedIndex: 0
        }
    }

    render() {
        const {selectedIndex} = this.state
        return (
            <div>
                <TabControl titles={this.titles} 
                tabControlClick={this.tabControlClick.bind(this)}/>
                <span>{this.titles[selectedIndex]}</span>
            </div>
        )
    }

    tabControlClick(index) {
        this.setState({
            selectedIndex: index
        })
    }
}